﻿
// 项目展示地址:"http://www.ddxc.org/"
// 如果你有什么好的建议或者觉得可以加什么功能，请加QQ群：104390185大家交流沟通
// 项目展示地址:"http://www.yoyocms.com/"
//博客地址：http://www.cnblogs.com/wer-ltm/
//代码生成器帮助文档：http://www.cnblogs.com/wer-ltm/p/5777190.html
// <Author-作者>角落的白板笔</Author-作者>
// Copyright © YoYoCms@中国.2017-11-22T22:16:56. All Rights Reserved.
//<生成时间>2017-11-22T22:16:56</生成时间>
using Abp.Application.Services.Dto;
using Abp.Web.Models;
using Abp.Web.Mvc.Authorization;
using KDS.Mes.Authorization;
using KDS.Mes.Mes.Andons;
using KDS.Mes.Mes.Andons.Dtos;
using KDS.Mes.Mes.Parts.Dtos;

using KDS.Mes.Web.Controllers;
using KDS.Mes.Web.Models.ANDON;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace KDS.Mes.Web.Controllers
{
    public class ANDONController : MesControllerBase
    {

        private readonly IANDONAppService _aNDONAppService;

        public ANDONController(IANDONAppService aNDONAppService)
        {
            _aNDONAppService = aNDONAppService;
           
        }

     
        public async Task<ActionResult> Index()
        {

           // var cartypes = new List<ComboboxItemDto>();
            //var getCartypesOutput = await _cartypeAppService.GetCartypes(new GetCartypeInput());
            //cartypes = getCartypesOutput.Items.Select(r => new ComboboxItemDto(r.Id.ToString(), r.CartypeName)).ToList();

            //var styles = new List<ComboboxItemDto>();
            //var getStylesOutput = await _styleAppService.Getstyles(new GetStyleInput());
            //styles = getStylesOutput.Items.Select(r => new ComboboxItemDto(r.Id.ToString(), r.StyleName)).ToList();

            //var seatPositions = new List<ComboboxItemDto>();
            //var getSeatPositionOutput = await _seatPositionAppService.GetSeatPositions(new GetSeatPositionInput());
            //seatPositions = getSeatPositionOutput.Items.Select(r => new ComboboxItemDto(r.Id.ToString(), r.SeatPositionName)).ToList();

            //cartypes.Insert(0, new ComboboxItemDto("", ""));
            //styles.Insert(0, new ComboboxItemDto("", ""));
            //seatPositions.Insert(0, new ComboboxItemDto("", ""));
           

            return View();
            //var model = new GetPartInput {FilterText = Request.QueryString["filterText"]};
            //return View();
        }
        [DontWrapResult]
        public JsonResult GetAllANDONs(int limit, int offset, string sortfiled, string sortway
                                       )
        {
            var sort = !string.IsNullOrEmpty(sortfiled) ? string.Format("{0} {1}", sortfiled, sortway) : "";
            var filter = new GetANDONInput
            {
                SkipCount = offset,
                MaxResultCount = limit,
                Sorting = sort,
               
            };
            var pagedTasks = _aNDONAppService.GetPagedANDONs(filter);
            var j=Json(new { total = pagedTasks.TotalCount, rows = pagedTasks.Items }, JsonRequestBehavior.AllowGet);
            return Json(new { total = pagedTasks.TotalCount, rows = pagedTasks.Items }, JsonRequestBehavior.AllowGet);

        }
        [AbpMvcAuthorize(AppPermissions.Pages_Basic_Factorys_Create, AppPermissions.Pages_Basic_Factorys_Edit)]
        public async Task<PartialViewResult> CreateOrEditANDONModal(int? id)
        {
            var input = new NullableIdDto<int> { Id = id };

            var output = await _aNDONAppService.GetANDONForEditAsync(input);

            var viewModel = new CreateOrEditANDONModalViewModel(output);


            return PartialView("_CreateOrEditANDONModal", viewModel);
        }

    }
}